{% extends "templates/base.html" %}

{% block csslink %}
		{{ super() }}
        <script src="/media/js/jquery.js"></script>
{% endblock %}

{% block title %} 
	{{ title }}
{% endblock %}

{% block header %}
{{ header }}
{% endblock %}

{% block login%}
{% if show_login %}
{{ super() }}
{% endif %}
{% endblock%}

{% block navigation %}
{% if not show_login %}
{{ super() }}
{% endif %}
{% endblock %}

{% block page_name %}
{{ content_header }}
{% endblock %}

{% block main_content %}
<p>
	{% if syndic %}
	<a href="/ams/syndic/{{ syndic.key().id() }}/detail/">Back to {{ syndic.name }}</a>
	{% else %}
	<a href="/ams/syndic/">Back to the list of syndics</a>
	{% endif %}
	<form method="POST" action="">
	<fieldset>
    <legend>Identification du syndic</legend>
		<div class="div-table">
		{% if main_content.note != "" %}
			<div class="div-table-row">
				<div class="div-table-col-header"></div>
				<div class="div-table-col">
						<div class="ok">{{ main_content.note }}</div>
				</div>
			</div>
		{% endif %}
				
		{% for field in main_content.form %}
			<div class="div-table-row">
				<div class="div-table-col-header">
					{{ field.label.text }}{% if "required" in field.flags %}<div class="error" style="display: inline;">*</div>{% endif %}:
				</div>
				<div class="div-table-col">
					{{ field }}
					{% if field.errors %}
						{% for error in field.errors %}
							<li class="error">{{error}}</li>
						{% endfor %}
					{% endif %}
				</div>
			</div>
		{% endfor %}
		</div>
		<div class="submit">
			<input type="submit" value="Save">
		</div>
	</form>
</p>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
	var change_syn_type = function (obj) {
		if ($(obj).val() == "Professional") {
			$("#capital").closest(".div-table-row").show();
			$("#siret").closest(".div-table-row").show();
			$("#ape").closest(".div-table-row").show();
			$("#carteprof_g").closest(".div-table-row").show();
			$("#carteprof_t").closest(".div-table-row").show();
			$("#caissegarant").closest(".div-table-row").show();
			$("#n_dadherent").closest(".div-table-row").show();
			$("#caisse_adress").closest(".div-table-row").show();
			$("#tva_num").closest(".div-table-row").show();
		}
		else {
			$("#capital").closest(".div-table-row").hide();
			$("#siret").closest(".div-table-row").hide();
			$("#ape").closest(".div-table-row").hide();
			$("#carteprof_g").closest(".div-table-row").hide();
			$("#carteprof_t").closest(".div-table-row").hide();
			$("#caissegarant").closest(".div-table-row").hide();
			$("#n_dadherent").closest(".div-table-row").hide();
			$("#caisse_adress").closest(".div-table-row").hide();
			$("#tva_num").closest(".div-table-row").hide();
		}
	};
	
	change_syn_type($("#type"));
	
	$("#type").change(function() {
		change_syn_type(this);
	});
});
</script>
{% endblock %}
